package com.mohunhun.controller;

import com.mohunhun.common.AppResult;
import com.mohunhun.exception.ApplicationException;
import com.mohunhun.model.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
@Tag(name = "测试类的相关接口")
public class TestController {

    @GetMapping("/hello")
    @Operation(summary = "欢迎接口")
    public String hello(@Parameter(description = "姓名") @RequestParam("name") String name) {
        return "Hello, " + name + "!";
    }

    @GetMapping("/applicationException")
    @Operation(summary = "测试自定义异常")
    public AppResult testApplicationException() {
        throw new ApplicationException("这是自定义异常");
    }

    @GetMapping("/exception")
    @Operation(summary = "测试系统异常")
    public AppResult testException() throws Exception {
        throw new Exception("这是 Exception");
    }


}